var Relation = require('../relation');
var User = require('../user')
var Card = require('../card')
var Activity = require('../activity');
var initRedisCache = require('../../lib/InitRedisCache');
var Faction = require('../faction');
var fmproxy = require('../factionmember');
var Creditspolicy = require('../creditspolicy');
var FactionMember = require('../../entity').FactionMember;
var activity = require('../../entity').Activity;
var UserE = require('../../entity').User;
var CardE = require('../../entity').Card;



function check(){
    var actId = '54377a909a54b8ed0af457b1';
    var userId = '5437ca295fa035fb22be2f97';
    activity.findOne({_id: actId}).exec(function(err, act){
        var attends = act.attends;
        var map = {};
        var result = [];
        for(var i=0; i<attends.length; i++){
            if(!map[attends[i].id]){
                result.push(attends[i]);
            }else{
                console.log('tick :'+attends[i])
            }
        }
        activity.update({_id: act._id}, {$set: {attends: result}}, {}, function(err, data){
            console.log(data);
        })
    })
}

check();